<!--
 * @Description: 项目经理月报评价
 * @Author: wind-lc
 * @version: 1.0
 * @Date: 2022-04-07 18:00:36
 * @LastEditTime: 2022-04-19 17:57:26
 * @FilePath: \cscec-pms-admin\src\views\project\projectManagerMonthlyReportEvaluate\projectManagerMonthlyReportEvaluateView.vue
-->
<template>
  <base-breadcrumb>
    <a-spin :spinning="loading">
      <a-card>
        <title-name title="基本信息" />
        <custom-form
          ref="form"
          :is-validate="true"
          :edit-model="''"
          :form="form"
          :form-list="formOption"
        />
      </a-card>
      <a-card>
        <a-tabs v-model="tabKey">
          <a-tab-pane
            key="1"
            tab="分公司评价"
          />
          <a-tab-pane
            v-if="isImportant"
            key="2"
            tab="公司评价"
          />
        </a-tabs>
        <a-table
          ref="table"
          :columns="columns1"
          :data-source="tabKey === '1' ? branchComEvaluation : tabKey === '2' ? companyEvaluation : []"
          :pagination="false"
          bordered
          row-key="id"
        />
      </a-card>
      <div class="pub-next-btn">
        <a-button @click="$close">
          关闭
        </a-button>
      </div>
    </a-spin>
  </base-breadcrumb>
</template>
<script>
import { formOption, columns1, important } from './model.js'
import { view } from '@/api/project/projectManagerMonthlyReportEvaluate'
export default {
  name: 'projectManagerMonthlyReportEvaluateView' + Date.now(),
  props: {
    // 审批时
    isAudit: {
      type: Boolean,
      default: false
    }
  },
  components: {},
  data() {
    return {
      // 加载
      loading: false,
      // 基本信息表单
      form: {},
      // 基本信息表单选项
      formOption,
      // 重点项目
      isImportant: false,
      // 标签页显示项
      tabKey: '1',
      // 评价表头
      columns1,
      // 分公司评价表数据
      branchComEvaluation: [],
      // 公司评价表数据
      companyEvaluation: []
    }
  },
  computed: {
    // 地址携带信息
    info() {
      return this.$route.query
    }
  },
  mounted() {
    this.getData()
  },
  methods: {
    /**
     * @description: 获取数据
     * @param {void}
     * @return {void}
     */
    async getData() {
      this.loading = true
      try {
        const { data } = await view.queryProjectManagerMonthlyReportEvaluationDetail(this.info.id)
        // 基本信息
        this.formOption.forEach((el) => {
          if (data[el.keyName]) {
            this.$set(this.form, el.keyName, el.keyName === 'isImportant' ? important.find((item) => item.value === data[el.keyName])?.label : data[el.keyName])
          }
        })
        // 是否重点项目
        this.isImportant = data.isImportant === '1'
        // 分公司评价
        this.branchComEvaluation = data.branchComEvaluation
        if (this.isImportant) {
          // 公司评价
          this.companyEvaluation = data.companyEvaluation
        }
      } catch (error) {
        console.log(error)
      } finally {
        this.loading = false
      }
    }
  }
}
</script>
<style lang="less" scoped>
</style>

